<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="feedbackList.title"/></title>
    <meta name="menu" content="FeedbackMenu"/>
</head>

<h2><fmt:message key="feedbackList.heading"/></h2>

<p><fmt:message key="feedbackList.message"/></p>

<display:table name="loanRequest.feedbackList" class="table table-condensed table-striped table-hover" requestURI="" id="feedbackList" export="false" pagesize="25">
    <display:column property="id" sortable="true" href="feedbackform" media="html"
        paramId="id" paramProperty="id" titleKey="feedback.id"/>
    <display:column property="id" media="csv excel xml pdf" titleKey="feedback.id"/>
    <display:column property="operator" sortable="true" titleKey="feedback.operator"/>
    <display:column sortProperty="time" sortable="true" titleKey="feedback.time">
         <fmt:formatDate value="${feedbackList.time}" pattern="${datePattern}"/>
    </display:column>
    <display:column sortable="true" titleKey="feedback.reqStatus">
        <fmt:message key="REQUEST_STATUS_${feedbackList.reqStatus}"/>
    </display:column>
    <display:column sortProperty="read" sortable="true" titleKey="feedback.read">
        <input type="checkbox" disabled="disabled" <c:if test="${feedbackList.read}">checked="checked"</c:if>/>
    </display:column>
    <display:column property="content" sortable="true" titleKey="feedback.content"/>

    <display:setProperty name="paging.banner.item_name"><fmt:message key="feedbackList.feedback"/></display:setProperty>
    <display:setProperty name="paging.banner.items_name"><fmt:message key="feedbackList.feedbacks"/></display:setProperty>

    <display:setProperty name="export.excel.filename"><fmt:message key="feedbackList.title"/>.xls</display:setProperty>
    <display:setProperty name="export.csv.filename"><fmt:message key="feedbackList.title"/>.csv</display:setProperty>
    <display:setProperty name="export.pdf.filename"><fmt:message key="feedbackList.title"/>.pdf</display:setProperty>
</display:table>

</br>

<div class="col-sm-6">
    <form:errors path="*" cssClass="alert alert-danger alert-dismissable" element="div"/>
    <form:form commandName="feedback" method="post" action="requestfeedback" cssClass="well"
               id="feedbackForm" onsubmit="return validateFeedback(this)">
        <form:hidden path="id"/>
        <input type="hidden" name="reqId" value="<c:out value="${loanRequest.id}"/>"/>
        <spring:bind path="feedback.content">
            <div class="form-group${(not empty status.errorMessage) ? ' has-error' : ''}">
        </spring:bind>
        <appfuse:label key="feedback.content" styleClass="control-label"/>
        <form:input cssClass="form-control" path="content" id="content"  maxlength="255"/>
        <form:errors path="content" cssClass="help-block"/>
        </div>
        <spring:bind path="feedback.operator">
            <div class="form-group${(not empty status.errorMessage) ? ' has-error' : ''}">
        </spring:bind>
        <appfuse:label key="feedback.operator" styleClass="control-label"/>
        <form:input cssClass="form-control" path="operator" id="operator"  maxlength="255"/>
        <form:errors path="operator" cssClass="help-block"/>
        </div>
        <spring:bind path="feedback.read">
            <div class="form-group${(not empty status.errorMessage) ? ' has-error' : ''}">
        </spring:bind>
        <appfuse:label key="feedback.read" styleClass="control-label"/>
        <form:checkbox path="read" id="read" cssClass="checkbox"/>
        <form:errors path="read" cssClass="help-block"/>
        </div>
        <spring:bind path="feedback.reqStatus">
            <div class="form-group${(not empty status.errorMessage) ? ' has-error' : ''}">
        </spring:bind>
        <appfuse:label key="feedback.reqStatus" styleClass="control-label"/>
        <form:input cssClass="form-control" path="reqStatus" id="reqStatus"  maxlength="255"/>
        <form:errors path="reqStatus" cssClass="help-block"/>
        </div>
        <spring:bind path="feedback.time">
            <div class="form-group${(not empty status.errorMessage) ? ' has-error' : ''}">
        </spring:bind>
        <appfuse:label key="feedback.time" styleClass="control-label"/>
        <form:input cssClass="form-control" path="time" id="time" size="11" title="date" datepicker="true"/>
        <form:errors path="time" cssClass="help-block"/>
        </div>

        <div class="form-group">
            <button type="submit" class="btn btn-primary" id="save" name="save" onclick="bCancel=false">
                <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/>
            </button>
            <c:if test="${not empty feedback.id}">
                <button type="submit" class="btn btn-danger" id="delete" name="delete" onclick="bCancel=true;return confirmMessage(msgDelConfirm)">
                    <i class="icon-trash icon-white"></i> <fmt:message key="button.delete"/>
                </button>
            </c:if>
        </div>
    </form:form>
</div>

<v:javascript formName="feedback" cdata="false" dynamicJavascript="true" staticJavascript="false"/>
<script type="text/javascript" src="<c:url value='/scripts/validator.jsp'/>"></script>

<link rel="stylesheet" type="text/css" media="all" href="<c:url value='/webjars/bootstrap-datepicker/1.3.1/css/datepicker.css'/>" />
<script type="text/javascript" src="<c:url value='/webjars/bootstrap-datepicker/1.3.1/js/bootstrap-datepicker.js'/>"></script>
<c:if test="${pageContext.request.locale.language != 'en'}">
    <script type="text/javascript" src="<c:url value='/webjars/bootstrap-datepicker/1.3.1/js/locales/bootstrap-datepicker.${pageContext.request.locale.language}.js'/>"></script>
</c:if>
<c:set var="scripts" scope="request">
<script type="text/javascript">
    $(document).ready(function() {
        $("input[type='text']:visible:enabled:first", document.forms['feedbackForm']).focus();
        $('.text-right.date').datepicker({format: "<fmt:message key='calendar.format'/>", weekStart: "<fmt:message key='calendar.weekstart'/>", language: '${pageContext.request.locale.language}'});
    });
</script>
</c:set>